<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>LibQQt: QQtProtocolManager Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">LibQQt
   &#160;<span id="projectnumber">v3.1</span>
   </div>
   <div id="projectbrief">开源、跨平台Qt应用程序框架中间件</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#signals">Signals</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="class_q_qt_protocol_manager-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">QQtProtocolManager Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>The <a class="el" href="class_q_qt_protocol_manager.html" title="The QQtProtocolManager class very good ideology and impliment 用于管理多个Protocol实例 用户实现的协议...">QQtProtocolManager</a> class very good ideology and impliment 用于管理多个Protocol实例 用户实现的协议注册到这里，当协议当中有消息需要告知业务层，从这里告知。  
 <a href="class_q_qt_protocol_manager.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="qqtprotocolmanager_8h_source.html">qqtprotocolmanager.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for QQtProtocolManager:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_q_qt_protocol_manager.png" usemap="#QQtProtocolManager_map" alt=""/>
  <map id="QQtProtocolManager_map" name="QQtProtocolManager_map">
<area href="class_q_qt_named_pipe_server_protocol_manager.html" alt="QQtNamedPipeServerProtocolManager" shape="rect" coords="0,112,236,136"/>
<area href="class_q_qt_server_protocol_manager.html" title="The QQtServerProtocolManager class ... " alt="QQtServerProtocolManager" shape="rect" coords="246,112,482,136"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="signals"></a>
Signals</h2></td></tr>
<tr class="memitem:aac4faf21da374d2371f3ecc25324c5ed"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_q_qt_protocol_manager.html#aac4faf21da374d2371f3ecc25324c5ed">notifyToBusinessLevel</a> (const <a class="el" href="class_q_qt_protocol.html">QQtProtocol</a> *protocol, const <a class="el" href="class_q_qt_message.html">QQtMessage</a> *message)</td></tr>
<tr class="memdesc:aac4faf21da374d2371f3ecc25324c5ed"><td class="mdescLeft">&#160;</td><td class="mdescRight">notifyToUser 这个信号是给用户的，用户可以接收下来，转换为自己的协议使用。注释：如果必要。 用户使用这个ProtocolManager，Protocol需要提交给用户处理的命令，提交到这里，在这里提交给用户。 ProtocolManager -&gt; BusinessLevel  <a href="#aac4faf21da374d2371f3ecc25324c5ed">More...</a><br /></td></tr>
<tr class="separator:aac4faf21da374d2371f3ecc25324c5ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5df5b4446ea8265671812ab8d7d7252f"><td class="memItemLeft" align="right" valign="top"><a id="a5df5b4446ea8265671812ab8d7d7252f"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>remanentProtocolChanged</b> (int num)</td></tr>
<tr class="separator:a5df5b4446ea8265671812ab8d7d7252f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac5c8d1d4f008a425e91e62fd5986d80a"><td class="memItemLeft" align="right" valign="top"><a id="ac5c8d1d4f008a425e91e62fd5986d80a"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>remainingProtocolChanged</b> (int num)</td></tr>
<tr class="separator:ac5c8d1d4f008a425e91e62fd5986d80a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a8dda4189f004e2013de7a51039319efa"><td class="memItemLeft" align="right" valign="top"><a id="a8dda4189f004e2013de7a51039319efa"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>QQtProtocolManager</b> (QObject *parent=0)</td></tr>
<tr class="separator:a8dda4189f004e2013de7a51039319efa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a82e23b25b4991b6b04969bab7645cb1a"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a82e23b25b4991b6b04969bab7645cb1a"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_q_qt_protocol_manager.html#a82e23b25b4991b6b04969bab7645cb1a">registerProtocol</a> (int count=1024)</td></tr>
<tr class="separator:a82e23b25b4991b6b04969bab7645cb1a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad9338cb29423bcb27e028b2fcc172111"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_q_qt_protocol.html">QQtProtocol</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_q_qt_protocol_manager.html#ad9338cb29423bcb27e028b2fcc172111">createProtocol</a> ()</td></tr>
<tr class="memdesc:ad9338cb29423bcb27e028b2fcc172111"><td class="mdescLeft">&#160;</td><td class="mdescRight">createProtocol 创建一个Protocol句柄，开始使用。  <a href="#ad9338cb29423bcb27e028b2fcc172111">More...</a><br /></td></tr>
<tr class="separator:ad9338cb29423bcb27e028b2fcc172111"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a144c24a9597d4fd2618b20f3389497f1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_q_qt_protocol_manager.html#a144c24a9597d4fd2618b20f3389497f1">deleteProtocol</a> (<a class="el" href="class_q_qt_protocol.html">QQtProtocol</a> *stack)</td></tr>
<tr class="separator:a144c24a9597d4fd2618b20f3389497f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:ad613f34535b4b40b189d11c40d354143"><td class="memItemLeft" align="right" valign="top"><a id="ad613f34535b4b40b189d11c40d354143"></a>
<a class="el" href="class_q_qt_protocol.html">QQtProtocol</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>findDetachedInstance</b> ()</td></tr>
<tr class="separator:ad613f34535b4b40b189d11c40d354143"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The <a class="el" href="class_q_qt_protocol_manager.html" title="The QQtProtocolManager class very good ideology and impliment 用于管理多个Protocol实例 用户实现的协议...">QQtProtocolManager</a> class very good ideology and impliment 用于管理多个Protocol实例 用户实现的协议注册到这里，当协议当中有消息需要告知业务层，从这里告知。 </p>
<p>注释： 讲解notify过程， QQtSocketServer，管理QQtSocketClient句柄 QQtProtocolManager，管理QQtProtocol句柄 cli -&gt; proto, dispatcher, recvFunc, notifyToProtocolManager, protoManager -&gt; businessLevel, 完全信号传递。</p>
<p>关于识别Protocl， 用户的客户端可以发个人信息上来，Protocol保存在句柄内部。</p>
<p>定位： 只可以安装同一种类型的句柄。 可以通过多次注册改变内部的句柄数量。</p>
<p>模型： 业 PM S 业 务 | | 务 层 P - C :: C - P 层 </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="ad9338cb29423bcb27e028b2fcc172111"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad9338cb29423bcb27e028b2fcc172111">&#9670;&nbsp;</a></span>createProtocol()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_q_qt_protocol.html">QQtProtocol</a> * QQtProtocolManager::createProtocol </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>createProtocol 创建一个Protocol句柄，开始使用。 </p>
<p>以下和用户无关 这个函数给QQtSocketServer用的，不是给用户用的。 用于生成用户协议对象实例。</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">protocolTypeName</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd></dd></dl>

</div>
</div>
<a id="a144c24a9597d4fd2618b20f3389497f1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a144c24a9597d4fd2618b20f3389497f1">&#9670;&nbsp;</a></span>deleteProtocol()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void QQtProtocolManager::deleteProtocol </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_q_qt_protocol.html">QQtProtocol</a> *&#160;</td>
          <td class="paramname"><em>stack</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>使用完，删除。</p>
<p>Protocol的deattach和这个功能不同，它表示使用状态切换为不使用。 而deleteProtocol表示，这个句柄要删除了。 如果只是deattach，那么这个句柄重新被attach以后，用户把内部的变量都reset了吗？其实如果reset了，不必要删除句柄。 但是，内部实现的，支持reset，在attach的时候调用。可是没有太多作用，因为，这个句柄在不用了的时候会在这里被delete掉。</p>
<p>这个机制会导致初始注册了一些句柄以后，使用使用就变少了，逐渐的就用完了。所以必须频繁根据句柄数量变动进行注册。 经过考虑，我决定不删除句柄，用户继承QQtProtocol句柄的时候override init函数初始化句柄，可以避免句柄逐渐变少引起的频繁注册。 Protocol的init函数，只需要在必要初始化句柄的时候重写。</p>
<p>内部没有对QList加锁，所以不要movetothread里用。 </p>

</div>
</div>
<a id="aac4faf21da374d2371f3ecc25324c5ed"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aac4faf21da374d2371f3ecc25324c5ed">&#9670;&nbsp;</a></span>notifyToBusinessLevel</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void QQtProtocolManager::notifyToBusinessLevel </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_q_qt_protocol.html">QQtProtocol</a> *&#160;</td>
          <td class="paramname"><em>protocol</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_q_qt_message.html">QQtMessage</a> *&#160;</td>
          <td class="paramname"><em>message</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">signal</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>notifyToUser 这个信号是给用户的，用户可以接收下来，转换为自己的协议使用。注释：如果必要。 用户使用这个ProtocolManager，Protocol需要提交给用户处理的命令，提交到这里，在这里提交给用户。 ProtocolManager -&gt; BusinessLevel </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">protocol</td><td></td></tr>
    <tr><td class="paramname">message</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a82e23b25b4991b6b04969bab7645cb1a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a82e23b25b4991b6b04969bab7645cb1a">&#9670;&nbsp;</a></span>registerProtocol()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool QQtProtocolManager::registerProtocol </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>count</em> = <code>1024</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>注册用户协议类型 模板函数 用于ProtocolManager内部生成用户协议实例。 这个用户在生成ProtocolManager对象的时候，需要注册一下自己的协议类，需要调用至少一次。</p>
<p>注意： registerProtocol&lt;QQtXXXProtocol&gt;(1); //这样只预备了一个句柄。 可以根据Protocol ObjectName区分Protocol 或者metaObject()-&gt;className()</p>
<p>用法： 用户连接remanentProtocolChanged，当发现小于某个约束数目的时候，就调用这个函数进行注册， 注册用户认为合理的数量即可。 如果客户端数量存在上限，调用一次这个函数就可以了，不必检测剩余句柄数目。默认一次创建1024个句柄。 </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>R:/Develop/a0-develop/LibQQt/src/network/<a class="el" href="qqtprotocolmanager_8h_source.html">qqtprotocolmanager.h</a></li>
<li>R:/Develop/a0-develop/LibQQt/src/network/qqtprotocolmanager.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>
